home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / dns / node.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  3KB  |  91 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. import StringIO
  5. import dns.rdataset as dns
  6. import dns.rdatatype as dns
  7. import dns.renderer as dns
  8.  
  9. class Node(object):
  10.     __slots__ = [
  11.         'rdatasets']
  12.     
  13.     def __init__(self):
  14.         self.rdatasets = []
  15.  
  16.     
  17.     def to_text(self, name, **kw):
  18.         s = StringIO.StringIO()
  19.         for rds in self.rdatasets:
  20.             print >>s, rds.to_text(name, **kw)
  21.         
  22.         return s.getvalue()[:-1]
  23.  
  24.     
  25.     def __repr__(self):
  26.         return '<DNS node ' + str(id(self)) + '>'
  27.  
  28.     
  29.     def __eq__(self, other):
  30.         for rd in self.rdatasets:
  31.             if rd not in other.rdatasets:
  32.                 return False
  33.                 continue
  34.         
  35.         for rd in other.rdatasets:
  36.             if rd not in self.rdatasets:
  37.                 return False
  38.                 continue
  39.         
  40.         return True
  41.  
  42.     
  43.     def __ne__(self, other):
  44.         return not self.__eq__(other)
  45.  
  46.     
  47.     def __len__(self):
  48.         return len(self.rdatasets)
  49.  
  50.     
  51.     def __iter__(self):
  52.         return iter(self.rdatasets)
  53.  
  54.     
  55.     def find_rdataset(self, rdclass, rdtype, covers = dns.rdatatype.NONE, create = False):
  56.         for rds in self.rdatasets:
  57.             if rds.match(rdclass, rdtype, covers):
  58.                 return rds
  59.                 continue
  60.         
  61.         if not create:
  62.             raise KeyError
  63.         
  64.         rds = dns.rdataset.Rdataset(rdclass, rdtype)
  65.         self.rdatasets.append(rds)
  66.         return rds
  67.  
  68.     
  69.     def get_rdataset(self, rdclass, rdtype, covers = dns.rdatatype.NONE, create = False):
  70.         
  71.         try:
  72.             rds = self.find_rdataset(rdclass, rdtype, covers, create)
  73.         except KeyError:
  74.             rds = None
  75.  
  76.         return rds
  77.  
  78.     
  79.     def delete_rdataset(self, rdclass, rdtype, covers = dns.rdatatype.NONE):
  80.         rds = self.get_rdataset(rdclass, rdtype, covers)
  81.         if rds is not None:
  82.             self.rdatasets.remove(rds)
  83.         
  84.  
  85.     
  86.     def replace_rdataset(self, replacement):
  87.         self.delete_rdataset(replacement.rdclass, replacement.rdtype, replacement.covers)
  88.         self.rdatasets.append(replacement)
  89.  
  90.  
  91.